﻿<UserControl x:Class="BookManagementWpfApplication.Views.UserControl.AddBookView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:vm="clr-namespace:BookManagementWpfApplication.ViewModels"
             xmlns:vu="clr-namespace:BookManagementWpfApplication.Views.UserControl"
             xmlns:converter="clr-namespace:BookManagementWpfApplication.Converters"
             FontFamily="Tahoma" FontSize="15"             
             mc:Ignorable="d" 
             d:DesignHeight="500" d:DesignWidth="970">
    
    <UserControl.Resources>
        <vm:AddBookViewModel x:Key="addBookViewModel" />
        <converter:BookStatusConvert x:Key="bookStatusConvert" />
        <converter:DateToYearConvert x:Key="dateToYearConvert" />
    </UserControl.Resources>
    
   <ScrollViewer DataContext="{Binding Source={StaticResource addBookViewModel}}">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="455" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        
        <Grid.RowDefinitions>
            <RowDefinition Height="60" />
            <RowDefinition Height="325" />
            <RowDefinition Height="46" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        
        <StackPanel Name="stackPanel1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Grid.ColumnSpan="2" Margin="0,16">
            <TextBlock Height="29" Name="textBlock1" Text="เพิ่มรายการหนังสือ" FontWeight="Bold" FontSize="22" Margin="20,0,0,0" />
        </StackPanel>
        
        <Rectangle Name="rectangle1" Stroke="Black" Width="auto" Height="1" Margin="7,54,5,0" Grid.ColumnSpan="2" />
        <Rectangle Height="322" HorizontalAlignment="Left" Margin="6,3,0,0" Name="rectangle2" Stroke="Black" VerticalAlignment="Top" Width="440" Grid.Row="1" />
        
        <StackPanel Grid.Row="1" Name="stackPanel2" HorizontalAlignment="Left" Margin="0,10,0,0">
            <StackPanel Name="stackPanel3" Orientation="Horizontal">
                <TextBlock Height="23" Name="textBlock2" Text="- ชื่อหนังสือ : " Margin="20,5,0,5" />
                <TextBox Height="23" Name="textBox1" Width="250" Margin="80,0,0,0" />
            </StackPanel>
            <StackPanel Name="stackPanel4" Orientation="Horizontal">
                <TextBlock Height="23" Name="textBlock3" Text="- ชื่อผู้แต่ง / ผู้แปล : " Margin="20,5,0,5" />
                <TextBox Height="23" Name="textBox2" Width="250" Margin="38,0,0,0" />
            </StackPanel>
            <StackPanel Name="stackPanel5" Orientation="Horizontal">
                <TextBlock Height="23" Name="textBlock4" Text="- ประเภท : " Margin="20,5,0,5" />
                <ComboBox Height="23" Name="comboBox1" Width="185" Margin="95,0,0,0" />
            </StackPanel>
            <StackPanel Name="stackPanel6" Orientation="Horizontal">
                <TextBlock Height="23" Name="textBlock5" Text="- วัน/เดือน/ปี ที่จัดซื้อ : " Margin="20,5,0,5" />
                <DatePicker Height="25" Name="datePicker1" Width="185" Margin="22,0,0,0" />
            </StackPanel>
            <StackPanel Name="stackPanel7" Orientation="Horizontal">
                <TextBlock Height="23" Name="textBlock6" Text="- เลขทะเบียนหนังสือ : " Margin="20,5,0,5" />
                <TextBox Height="23" Name="textBox3" Width="205" Margin="26,0,0,0" />
            </StackPanel>
            <StackPanel Name="stackPanel8" Orientation="Horizontal">
                <TextBlock Height="23" Name="textBlock7" Text="- รหัสบาร์โค้ด (ISBN) : " Margin="20,5,0,5" />
                <TextBox Height="23" Name="textBox4" Width="205" Margin="21,0,0,0" />
            </StackPanel>
            <StackPanel Name="stackPanel9" Orientation="Horizontal">
                <TextBlock Height="23" Name="textBlock8" Text="- หมายเหตุ : " Margin="20,5,0,77" />
                <TextBox Height="95" Name="textBox5" Width="250" Margin="85,5,0,5" />
            </StackPanel>
        </StackPanel>
        
        <StackPanel Grid.Row="2" Name="stackPanel10" Orientation="Horizontal" HorizontalAlignment="Left" Margin="132,0,0,0">
            <Button Content="บันทึก" Height="25" Name="saveButtonAddPage" Width="70" Margin="5,5,5,5" Click="saveButtonAddPage_Click" />
            <Button Content="ยกเลิก" Height="25" Name="button1" Width="70" Margin="5,5,5,5" Click="button1_Click" />
        </StackPanel>        
        
        <DataGrid AutoGenerateColumns="False" Grid.Row="1" Name="dataGrid1" ItemsSource="{Binding Path=BookICV}" Grid.Column="1" Margin="0,3,6,0" Background="#FFA1DAF2" AlternatingRowBackground="#FF2BDAFF">
            <DataGrid.Columns>                
                <DataGridTextColumn Header="รหัสหนังสือ" Width="auto" Binding="{Binding Path=BookCode}" />
                <DataGridTextColumn Header="ชื่อหนังสือ" Width="auto" Binding="{Binding Path=BookName}" />
                <DataGridTextColumn Header="ผู้แต่ง/ผู้แปล" Width="auto" Binding="{Binding Path=Writer}" />
                <DataGridTextColumn Header="ประเภทหนังสือ" Width="auto" Binding="{Binding Path=BookType}" />
                <DataGridTextColumn Header="ปีที่จัดซื้อ" Width="auto" Binding="{Binding Path=DateOfPurchase, Converter={StaticResource dateToYearConvert}}" />
                <DataGridTextColumn Header="ISBN" Width="auto" Binding="{Binding Path=ISBN}" />                
                <DataGridTextColumn Header="หมายเหตุ" Width="250" Binding="{Binding Path=RemarkOfBook}" />
            </DataGrid.Columns>
        </DataGrid>        
            <Rectangle Grid.ColumnSpan="2" Grid.Row="2" Height="1" Name="rectangle3" Stroke="Black" Width="auto" Margin="0,41,0,0" />
        </Grid>
   </ScrollViewer>
</UserControl>
